/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package searchAction;

import com.opensymphony.xwork2.ActionSupport;
import Guestbook.*;
import java.util.List;

/**
 *
 * @author Tom
 */
public class searchAction extends ActionSupport {
    
    private List<GuestbookEntry> searchResult;
    private String autor;
    private String searchtext;
    
    
    @Override
    public String execute() throws Exception {
           
           
            
           setSearchtext(this.searchtext.toUpperCase());
           //String author = this.autor.toLowerCase();
           
           
           
           GuestbookDB db = GuestbookDB.getInstance();
           
           /*
           try {
               ArrayList<GuestbookEntry> searchResult = new ArrayList<GuestbookEntry>();
               List<GuestbookEntry> allEntries = db.getAllEntries();
               
               for(GuestbookEntry entry : allEntries) {
                   if(entry.getText().toLowerCase().contains(searchText) 
                           && entry.getAuthor().toLowerCase().contains(author)) {
                       searchResult.add(entry);
                   }
               }
               
           } catch (DatabaseException e) {
               
           }
        
           */ 
           return SUCCESS;
       
    }
    
    public String getAutor() {
        return autor;
    }
    
    public void setAutor(String autor) {
        this.autor = autor;
    }
    
    public String getSearchtext() {
        return searchtext;
    }
    
    public void setSearchtext(String searchtext) {
        this.searchtext = searchtext;
    }
    
    public List<GuestbookEntry> getSearchResult() {
        return searchResult;
    }
    
    public void setSearchResult(List<GuestbookEntry> searchResult) {
        this.searchResult = searchResult;
    } 
}